"""
  模块描述：
  @author 8526
  @date 2022-05-13 9:47:22
  版权所有 Copyright www.dahantc.com
"""

import common.util as util
import voice.param as param
import voice.voiceapi as api

smsClient = api.VoiceSmsClient('http://180.168.192.126:16766')
pwdMd5 = util.md5Encode("456.com")
account = "dhst8526"


# 验证码提交调用demo
def captchaSubmitDemo():
    mediaParam = param.CaptchaVoiceParam(account, pwdMd5, 'true',
                                         [param.CaptchaVoiceData(None, '157****6131', '555559', 0, 1, None)])
    print('验证码提交响应', smsClient.captchaSubmit(mediaParam))


# 文本外呼调用demo
def textSubmitDemo():
    mediaParam = param.TextVoiceParam(account, pwdMd5, 'true',
                                      [param.TextVoiceData(None, '157****6131', '这是一条TTS的测试消息', 0, 0, 1, 1, None)])
    print('文本外呼提交响应', smsClient.textSubmit(mediaParam))


# 混合呼叫调用demo
def mixSubmitDemo():
    mediaParam = param.MixVoiceParam(account, pwdMd5, 'true',
                                     [param.MixVoiceData(None, '157****6131', 'a81dfae08b4b478cbc266d77aefbbb03',
                                                         '这是一条TTS的测试消息', 2, 3, None)])
    print('混合呼叫响应', smsClient.mixSubmit(mediaParam))


# 语音文件验证码调用demo
def mediaCaptchaSubmitDemo():
    mediaParam = param.MediaCaptchaParam(account, pwdMd5, 'true',
                                         [param.MediaCaptchaData(None, '157****6131',
                                                                 'a81dfae08b4b478cbc266d77aefbbb03',
                                                                 '888888', 3, 1)])
    print('语音文件验证码响应', smsClient.mediaCaptchaSubmit(mediaParam))


# 语音文件验证码调用demo
def mediaSubmitDemo():
    mediaParam = param.MediaVoiceParam(account, pwdMd5, 'true',
                                       [param.MediaVoiceData(None, '157****6131', 'a81dfae08b4b478cbc266d77aefbbb03',
                                                             1, 2, None)])
    print('语音文件验证码响应', smsClient.mediaSubmit(mediaParam))


# 语音素材上传调用demo
def vocMediaUploadDemo():
    filedata = util.FileUtil.getBase64Encode('C:\\temp\\1.wav')
    mediaParam = param.VocMediaUploadParam(account, pwdMd5, '1.wav', filedata)
    print('语音素材上传响应', smsClient.vocMediaUpload(mediaParam))


if __name__ == '__main__':
    captchaSubmitDemo()
    print('-----------------------------')
    textSubmitDemo()
    print('-----------------------------')
    mixSubmitDemo()
    print('-----------------------------')
    mediaCaptchaSubmitDemo()
    print('-----------------------------')
    mediaSubmitDemo()
    print('-----------------------------')
    vocMediaUploadDemo()
